package db;

import db.domain.Role;
import sf.database.annotations.SmallResults;
import sf.database.annotations.Tail;
import sf.database.annotations.Type;
import sf.database.jdbc.extension.ObjectJsonMapping;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.FieldResult;
import java.sql.Types;
import java.util.List;
import java.util.Map;

//此注解框架实现:主要解决子对象的创建问题.
@SmallResults({@FieldResult(name = "metaResult.userId", column = "id"/*对应别名*/),
        @FieldResult(name = "metaResult.icon", column = "icon"/*对应别名*/)})
public class UserResult {
    private Long id;

    @Column(name = "login_name")
    private String loginName;// 登陆名

    private String password;

    private String nicename;

    private MetaResult metaResult;

    private Integer status;

    @Tail
    private Map<String,Object> map;

    private List<Role> roles;

    @Type(ObjectJsonMapping.class)
    private Map<String,Object> maps1;

    @Type(javaType = String.class, sqlType = Types.CLOB)
    @Convert(converter = ObjectJsonConverter.class)
    private Map maps2;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getNicename() {
        return nicename;
    }

    public void setNicename(String nicename) {
        this.nicename = nicename;
    }

    public MetaResult getMetaResult() {
        return metaResult;
    }

    public void setMetaResult(MetaResult metaResult) {
        this.metaResult = metaResult;
    }

    public Map<String, Object> getMap() {
        return map;
    }

    public void setMap(Map<String, Object> map) {
        this.map = map;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public List<Role> getRoles() {
        return roles;
    }

    public void setRoles(List<Role> roles) {
        this.roles = roles;
    }

    public Map<String, Object> getMaps1() {
        return maps1;
    }

    public void setMaps1(Map<String, Object> maps1) {
        this.maps1 = maps1;
    }

    public Map getMaps2() {
        return maps2;
    }

    public void setMaps2(Map maps2) {
        this.maps2 = maps2;
    }
}
